// #ifdef H5
import Wx from "weixin-js-sdk";
import Sign from "./sign.js";

const Share = {
	data() {
		return {
			share: {
				title: document.title || Site.title,
				link: window.location.href,
				success: () => {}
			}
		}
	},
	watch: {
		share: {
			handler: function() {
				this.__share();
			},
			deep: true
		},
	},
	onLoad() {
		this.__sign();
	},
	methods: {
		__sign: function() {
			let url = location.href.split('#')[0];
			Sign.wxSign(url).then(res => {
				this.__share();
			});
		},
		__share: function() {
			Wx.onMenuShareAppMessage(this.share);
		}
	}
}
// #endif

// #ifndef H5
const Share = {}
// #endif

export default Share
